package com.medisched.medisched.controller;

import com.medisched.medisched.domain.Role;
import com.medisched.medisched.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 角色Controller
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@CrossOrigin
@RestController
@RequestMapping("/system/role")
public class RoleController
{
    @Autowired
    private IRoleService roleService;

    /**
     * 查询角色列表
     */
    @GetMapping("/list")
    public List<Role> list(Role role)
    {
        List<Role> list = roleService.selectRoleList(role);
        return list;
    }

    /**
     * 获取角色详细信息
     */
    @GetMapping(value = "/{id}")
    public Role getInfo(@PathVariable("id") Long id)
    {
        return (roleService.selectRoleById(id));
    }

    /**
     * 新增角色
     */
    @PostMapping
    public int add(@RequestBody Role role)
    {
        return (roleService.insertRole(role));
    }

    /**
     * 修改角色
     */
    @PutMapping
    public int edit(@RequestBody Role role)
    {
        return (roleService.updateRole(role));
    }

    /**
     * 删除角色
     */
	@DeleteMapping("/{ids}")
    public int remove(@PathVariable Long[] ids)
    {
        return (roleService.deleteRoleByIds(ids));
    }
}
